package com.example.exercise.xiaodemos;

import org.lionsoul.ip2region.xdb.Searcher;

/**
 * 根据ip获取地区
 */
public class IP2RegionDemo {

    public static void main(String[] args) {
        String ip = "20.205.243.166";
        String dbPath = "D:/ip2region.xdb";
        try {
            //直接从xdb文件获取数据，不加载数据到缓存
            Searcher searcher = Searcher.newWithFileOnly(dbPath);
            //一次性加载到缓存
//            Searcher searcher = Searcher.loadContentFromFile(dbPath);
            System.out.println(searcher.search(ip));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
